package cn.kgc.watch.service.impl;

import cn.kgc.watch.entity.User;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import cn.kgc.watch.mapper.UserMapper;
import cn.kgc.watch.service.UserService;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class UserServiceImpl implements UserService{

    @Resource
    private UserMapper userMapper;

    @Override
    public User findUser(User user) {
        return this.userMapper.selectUser(user);
    }

    @Override
    public void modifyLoginTime(Integer userId, Date date) {
        this.userMapper.updateLoginTime(userId,date);
    }

    @Override
    public Integer findUserName(String userNameCheck) {
        Integer num = this.userMapper.selectUserName(userNameCheck);
        System.out.println("num = " + num);
        return num;
    }
    @Transactional
    @Override
    public void addUser(User user) {
        this.userMapper.insertUser(user);
    }

    @Override
    public Integer findUserPassword(Integer userId,String password) {
        return this.userMapper.selectUserPassword(userId,password);
    }

    @Override
    public void modifyPassword(User user) {
        this.userMapper.updatePassword(user);
    }
}
